package books;

import org.joda.time.DateTime;

import util.Entity;
import builders.BookBuilder;

/**
 * Represents a physical copy of a book. Available.
 */
public class Book extends Entity {

    private static final long serialVersionUID = 1L;

    private BookInfo info;

    private boolean available;

    private long code;

    private DateTime registrationDate;

    public Book() {
        super();
        // empty constructor
    }

    public Book(final BookInfo anInfo, final long aCode) {
        super();
        this.available = true;
        this.code = aCode;
        this.info = anInfo;
        this.registrationDate = new DateTime();
    }

    public Book(final BookBuilder builder) {
        super();
        this.available = builder.isAvailable();
        this.code = builder.getCode();
        this.registrationDate = builder.getRegistrationDate();
        this.info = builder.getInfo();
    }

    public BookInfo getInfo() {
        return this.info;
    }

    public void setInfo(final BookInfo info) {
        this.info = info;
    }

    public boolean isAvailable() {
        return this.available;
    }

    public void setAvailable(final boolean available) {
        this.available = available;
    }

    public void setRegistrationDate(final DateTime aDate) {
        this.registrationDate = aDate;
    }

    public DateTime getRegistrationDate() {
        return this.registrationDate;
    }

    public long getCode() {
        return this.code;
    }

    public void setCode(final long aCode) {
        this.code = aCode;
    }

}
